<?php
namespace Home\Controller;
use Think\Controller;
class ResouseController extends Controller {
    public function index(){
    	  	
    	$this->display();
    }
    
    public function revise(){
    	if(M('combo')->where('1')->delete() === false || M('resouse')->where('1')->delete() === false){
    		return ajaxReturn(0,'删除原数据失败');
    	}
    	
    	foreach($_POST['dataKey'] as $k => $v){
//  		$data[] = array('key' =>$_POST['dataKey'][$k], 'value' =>$_POST['dataValue'][$k], 'window' =>$_POST['dataWindow'][$k], 'drive_id' =>$_POST['dataDrive'][$k]);
    		$data[] = array('key' =>$_POST['dataKey'][$k]);
    	}
    	
    	$res = D('resouse')->insertResouseList($data);
    	if(!$res){
    		return ajaxReturn(0,'添加失败');
    	}
    	$resSelect = D('resouse')->getResouseList();
    	if(!$resSelect){
    		return ajaxReturn(0,'查询新数据失败');
    	}
    	foreach($resSelect as $k => $v){
    		$dataInsert[] = array('resouse_id' => $v['id']);
    	}
    	$resInsert = D('combo')->insertComboList($dataInsert);
    	if(!$resSelect){
    		return ajaxReturn(0,'添加条件组合失败');
    	}
    	return ajaxReturn(1,'添加成功');
    }
    
}
?>